# -*- coding:utf-8 -*-

import httplib
import Models
class getmgr:
	def __init__(self, baseurl, suburl, port=80):
		self.__baseurl = baseurl
		self.__suburl = suburl
		self.__port =port
		self.__httpclient = None
	def __enter__(self):
		self.__httpclient = httplib.HTTPConnection(self.__baseurl, self.__port, timeout=30)
		self.__httpclient.request('GET', self.__suburl)
		response = self.__httpclient.getresponse()
		return response
	def __exit__(self, mytype, myvalue, tb):
		if self.__httpclient:
			self.__httpclient.close()

def mocklogin():
	with getmgr('10.97.87.8', '/pws/j_security_check?j_username=zhangyuxuan&j_password=jhjk123', 9083) as response:
		print response.status
		
def getListRawFile():
	with getmgr('10.97.87.200', '/eoms/portalQuery/queryWorkItem?userCode=zhangyuxuan&pageNum=1&listType=1&callback=callback', 9084) as response:
		responseStr = response.read()
		print responseStr
		return responseStr.replace('callback(','').replace(')','')

def getSheetList():
	h = Models.Record('','','','','www')
	return h.nexturl
		
		
		
if __name__=='__main__':
	getListRawFile()